#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdbool.h>

typedef struct stack
{
    int size;
    char* a;
}stack;
bool isValid(char* s) {
    stack st;
    st.size = 0;
    st.a = (char*)(malloc(sizeof(char) * 10000));
    for (int i = 0; s[i] != '\0'; ++i)
    {
        if (s[i] == '{' || s[i] == '(' || s[i] == '[')
        {
            st.a[st.size] = s[i];
            st.size++;
        }
        else
        {
            if (st.size == 0)
            {
                return false;
            }
            char ch = st.a[st.size - 1];
            st.size--;
            if (s[i] == ')' && ch == '(' || s[i] == '}' && ch == '{' || s[i] == ']' && ch == '[')
            {

            }
            else
            {
                return false;
            }
        }
    }
    if (st.size == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}